import { SocketContext } from '@/contexts/SocketProvider';
import { useContext } from 'react';

export const useSocket = () => {
	const context = useContext(SocketContext);
	if (context === undefined) {
		// 提供清晰的错误信息，帮助开发者正确使用
		throw new Error('useSocket must be used within a SocketProvider');
	}
	return context;
};